import Game

def GetOpertionString(game):
    if game.state == Game.state_input:
        return 'Set piece'
    elif game.state == Game.state_move:
        return 'Move piece'
    elif game.state == Game.state_catch:
        return "Catch other's piece, pieces left: {}".format(game.stateparam)
    elif game.state == Game.state_eat:
        return "Eat other's piece, pieces left: {}".format(game.stateparam)
    else:
        return "State Error!"
def Show(game):
    print("\nPlayer {}, {}".format(game.curplayer, GetOpertionString(game)))
    for y in range(5):
        strr = ''
        for x in range(5):
            strr += str(game.ground[x][y])
            strr += '  '
        print(strr)
        print('')

if __name__ == '__main__':
    game = Game.game()
    while game.state != Game.state_over:
        Show(game)
        piece = Game.pieceposition()
        piece2 = Game.pieceposition()
        if game.state == Game.state_input:
            piece.x = int(input('Select an empty position X: '))
            piece.y = int(input('Select an empty position Y: '))
            game.SetPiece(piece)
        elif game.state == Game.state_move:
            piece.x = int(input('Select piece position X: '))
            piece.y = int(input('Select piece position Y: '))
            piece2.x = int(input('Select an empty position X: '))
            piece2.y = int(input('Select an empty position Y: '))
            game.Move(piece, piece2)
        elif game.state == Game.state_catch:
            piece.x = int(input('Select other piece position X: '))
            piece.y = int(input('Select other piece position Y: '))
            game.Catch(piece)
        elif game.state == Game.state_eat:
            piece.x = int(input('Select other piece position X: '))
            piece.y = int(input('Select other piece position Y: '))
            game.Eat(piece)
        else:
            print("Error state!!!")
            break
    print('Player {} win!!!'.format(game.curplayer))
